use sqlx::{MySqlPool, mysql::MySqlPoolOptions};

use super::config::Database;

pub async fn sql_connect(dbs: Database) -> MySqlPool {
    let pool_connect = MySqlPoolOptions::new()
        .max_connections(5)
        .connect(&dbs.url)
        .await;
    match pool_connect {
        Ok(conn) => conn,
        Err(err) => {
            println!("err message: {:?}", err);
            panic!("数据库连接异常");
        },
    }
}